#ifndef __CM_NAT_CANDIDATE_H__
#define __CM_NAT_CANDIDATE_H__ 

#include "Common.h"
#include "tag.h"
#include "Poco/Net/SocketAddress.h"

using Poco::Net::SocketAddress;

namespace cm_nat
{
    using namespace cm_xmpp;

    class Candidate
    {
    public:
        Candidate();
        ~Candidate();

        void setLocalPrefernce(UInt32 localPref);

        UInt32 computePriority();

        Tag* tag();
        bool parse(const Tag* p_tag);
        Candidate* clone();

        typedef enum
        {
            CAND_TYPE_NULL       = 0x00,       
            CAND_TYPE_HOST       = 0x01,
            CAND_TYPE_STUN_REFLEX = 0x02,
            CAND_TYPE_PEER_REFLEX = 0x04,
            CAND_TYPE_RELAYED    = 0x08
        }CandidateType;

    public:
        UInt8 m_component;
        UInt8 m_foundation;
        UInt8 m_generation;
        std::string m_id;
        UInt8 m_network;
        std::string m_ip;
        UInt16 m_port;
        UInt32 m_priority;
        std::string m_protocol;

        std::string m_rel_addr;
        UInt16 m_rel_port;

        std::string m_type;

        UInt32 m_local_preference;
    };

    typedef std::list<Candidate*> CandidateList;
}
#endif